// pages/index/index.js
Page({
  
  /**
   * 页面的初始数据
   */
  data: {
    pageIndex: 1,
    background: [],
    notice:"欢迎来到医院预约挂号系统，请点击主页的挂号按钮进行预约挂号",
    articles: []
  },
  /**
   * 生命周期函数--监听页面加载
   */

  // acticleDetail() {
  //   console.log(2221)
  // },

  onLoad: function (options) {
    wx.request({
      url: 'https://118.31.170.229:5001/api/CjwArticleList/GetArticleList',
      method: 'get',
      data: {
        value: -1,
        pageIndex: 1,
        state: 1,
        pageSize: 10
      },
      success: (res) => {
          console.log(res)
          this.setData({
            background: res.data.articleLists
          })
      }
    })
    wx.request({
      url: 'https://118.31.170.229:5001/api/CjwArticleList/GetArticleList',
      method: 'get',
      data: {
        value: 1,
        pageIndex: 1,
        state: 1,
        pageSize: 5
      },
      success: (res) => {
          // console.log(res)
          this.setData({
            articles: res.data.articleLists
          })
          console.log(this.data.articles)
      }
    })
    wx.request({
      url: 'https://118.31.170.229:5001/api/CjwNoticeList/GetNoticeByNoticeId',
      method: 'get',
      data: {
        noticeId: 0,
      },
      success: (res) => {
          console.log(res)
          this.setData({
            notice: res.data.notice
          })
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    this.data.pageIndex += 1;
    console.log(this.data.pageIndex)
    wx.request({
      url: 'https://118.31.170.229:5001/api/CjwArticleList/GetArticleList',
      method: 'get',
      data: {
        value: 1,
        state: 1,
        pageIndex: this.data.pageIndex,
        pageSize: 5
      },
      success: (res) => {
        this.data.articles.push(...res.data.articleLists)
          this.setData({
            articles: this.data.articles
          })
          console.log(res)
          console.log(this.data.articles)
      }
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

  
})